# ccBitTorrent Environment Variables Configuration
# Copy this file to .env and modify values as needed
# All variables are prefixed with CCBT_ to avoid conflicts

# =============================================================================
# NETWORK CONFIGURATION
# =============================================================================

# Connection limits
CCBT_MAX_PEERS=200                    # Maximum global peers (1-10000)
CCBT_MAX_PEERS_PER_TORRENT=50        # Maximum peers per torrent (1-1000)
CCBT_MAX_CONNECTIONS_PER_PEER=1       # Max parallel connections per peer (1-8)

# Request pipeline settings
CCBT_PIPELINE_DEPTH=16                # Request pipeline depth (1-128)
CCBT_BLOCK_SIZE_KIB=16                # Block size in KiB (1-64)
CCBT_MIN_BLOCK_SIZE_KIB=4             # Minimum block size in KiB (1-64)
CCBT_MAX_BLOCK_SIZE_KIB=64            # Maximum block size in KiB (1-1024)

# Socket tuning
CCBT_SOCKET_RCVBUF_KIB=256            # Socket receive buffer size in KiB (1-65536)
CCBT_SOCKET_SNDBUF_KIB=256            # Socket send buffer size in KiB (1-65536)
CCBT_TCP_NODELAY=true                 # Enable TCP_NODELAY (true/false)

# Timeouts (seconds)
CCBT_CONNECTION_TIMEOUT=30.0          # Connection timeout (1.0-300.0)
CCBT_HANDSHAKE_TIMEOUT=10.0           # Handshake timeout (1.0-60.0)
CCBT_KEEP_ALIVE_INTERVAL=120.0        # Keep alive interval (30.0-600.0)
CCBT_PEER_TIMEOUT=60.0                # Peer inactivity timeout (5.0-600.0)
CCBT_DHT_TIMEOUT=2.0                  # DHT request timeout (1.0-60.0)

# Listen settings
CCBT_LISTEN_PORT=6881                 # Listen port (1024-65535)
CCBT_LISTEN_INTERFACE=0.0.0.0         # Listen interface
CCBT_ENABLE_IPV6=true                 # Enable IPv6 support (true/false)
CCBT_XET_PORT=                        # XET protocol port (uses listen_port_udp if not set) (1024-65535)
CCBT_XET_MULTICAST_ADDRESS=239.255.255.250 # XET multicast address for local network discovery
CCBT_XET_MULTICAST_PORT=6882          # XET multicast port (1024-65535)

# Transport protocols
CCBT_ENABLE_TCP=true                  # Enable TCP transport (true/false)
CCBT_ENABLE_UTP=false                 # Enable uTP transport (true/false)
CCBT_ENABLE_ENCRYPTION=false          # Enable protocol encryption (true/false)

# uTP (uTorrent Transport Protocol) Configuration (BEP 29)
CCBT_UTP_PREFER_OVER_TCP=true         # Prefer uTP over TCP when both are supported (true/false)
CCBT_UTP_CONNECTION_TIMEOUT=30.0      # uTP connection timeout in seconds (5.0-300.0)
CCBT_UTP_MAX_WINDOW_SIZE=65535        # Maximum uTP receive window size in bytes (8192-65535)
CCBT_UTP_MTU=1200                     # uTP MTU size (maximum UDP packet size) (576-65507)
CCBT_UTP_INITIAL_RATE=1500            # Initial send rate in bytes/second (1024-100000)
CCBT_UTP_MIN_RATE=512                 # Minimum send rate in bytes/second (256-10000)
CCBT_UTP_MAX_RATE=1000000            # Maximum send rate in bytes/second (10000-10000000)
CCBT_UTP_ACK_INTERVAL=0.1             # ACK packet send interval in seconds (0.01-1.0)
CCBT_UTP_RETRANSMIT_TIMEOUT_FACTOR=4.0 # RTT multiplier for retransmit timeout (2.0-10.0)
CCBT_UTP_MAX_RETRANSMITS=10           # Maximum retransmission attempts before connection failure (3-50)

# Choking strategy
CCBT_MAX_UPLOAD_SLOTS=4               # Maximum upload slots (1-20)
CCBT_OPTIMISTIC_UNCHOKE_INTERVAL=30.0 # Optimistic unchoke interval (1.0-600.0)
CCBT_UNCHOKE_INTERVAL=10.0            # Unchoke interval (1.0-600.0)

# IMPROVEMENT: Choking optimization weights
CCBT_CHOKING_UPLOAD_RATE_WEIGHT=0.6   # Weight for upload rate in choking/unchoking decisions (0.0-1.0)
CCBT_CHOKING_DOWNLOAD_RATE_WEIGHT=0.4  # Weight for download rate in choking/unchoking decisions (0.0-1.0)
CCBT_CHOKING_PERFORMANCE_SCORE_WEIGHT=0.2  # Weight for performance score in choking/unchoking decisions (0.0-1.0)

# IMPROVEMENT: Peer quality ranking weights
CCBT_PEER_QUALITY_PERFORMANCE_WEIGHT=0.4  # Weight for historical performance in peer quality ranking (0.0-1.0)
CCBT_PEER_QUALITY_SUCCESS_RATE_WEIGHT=0.2  # Weight for connection success rate in peer quality ranking (0.0-1.0)
CCBT_PEER_QUALITY_SOURCE_WEIGHT=0.2  # Weight for source quality in peer quality ranking (0.0-1.0)
CCBT_PEER_QUALITY_PROXIMITY_WEIGHT=0.2  # Weight for geographic proximity in peer quality ranking (0.0-1.0)

# Rate limiting (KiB/s, 0 = unlimited)
CCBT_GLOBAL_DOWN_KIB=0                # Global download limit (0+)
CCBT_GLOBAL_UP_KIB=0                  # Global upload limit (0+)
CCBT_PER_PEER_DOWN_KIB=0              # Per-peer download limit (0+)
CCBT_PER_PEER_UP_KIB=0                # Per-peer upload limit (0+)

# Tracker settings
CCBT_TRACKER_TIMEOUT=30.0             # Tracker request timeout (5.0-120.0)
CCBT_TRACKER_CONNECT_TIMEOUT=10.0     # Tracker connection timeout (1.0-60.0)
CCBT_TRACKER_CONNECTION_LIMIT=50      # Maximum tracker connections (1-200)
CCBT_TRACKER_CONNECTIONS_PER_HOST=10  # Max connections per tracker host (1-50)
CCBT_DNS_CACHE_TTL=300                # DNS cache TTL in seconds (60-3600)

# Connection pool settings
CCBT_CONNECTION_POOL_GRACE_PERIOD=60.0  # Grace period in seconds for new connections before quality checks (allows time for bandwidth establishment) (0.0-600.0)

# Connection health and failure management (BitTorrent spec compliant)
CCBT_MAX_CONCURRENT_CONNECTION_ATTEMPTS=20  # Maximum concurrent connection attempts to prevent OS socket exhaustion (5-100)
CCBT_CONNECTION_FAILURE_THRESHOLD=3  # Number of consecutive failures before applying backoff to a peer (1-10)
CCBT_CONNECTION_FAILURE_BACKOFF_BASE=2.0  # Exponential backoff base multiplier for connection failures (1.0-10.0)
CCBT_CONNECTION_FAILURE_BACKOFF_MAX=300.0  # Maximum backoff delay in seconds for failed connection attempts (60.0-3600.0)
CCBT_ENABLE_FAIL_FAST_DHT=true  # Enable fail-fast DHT trigger when active_peers == 0 for >30s (allows DHT even if <50 peers)
CCBT_FAIL_FAST_DHT_TIMEOUT=30.0  # Timeout in seconds before triggering fail-fast DHT when active_peers == 0 (10.0-120.0)

# BitTorrent Protocol v2 (BEP 52) settings
CCBT_PROTOCOL_V2_ENABLE=true          # Enable BitTorrent Protocol v2 support (BEP 52) (true/false)
CCBT_PROTOCOL_V2_PREFER=false         # Prefer v2 protocol when both v1 and v2 are available (true/false)
CCBT_PROTOCOL_V2_SUPPORT_HYBRID=true  # Support hybrid torrents (both v1 and v2 metadata) (true/false)
CCBT_PROTOCOL_V2_HANDSHAKE_TIMEOUT=30.0 # v2 handshake timeout in seconds (5.0-300.0)

# =============================================================================
# DISK CONFIGURATION
# =============================================================================

# Preallocation strategy: none, sparse, full, fallocate
CCBT_PREALLOCATE=full                 # Preallocation strategy
CCBT_SPARSE_FILES=false               # Use sparse files if supported (true/false)

# Write optimization
CCBT_WRITE_BATCH_KIB=64               # Write batch size in KiB (1-1024)
CCBT_WRITE_BUFFER_KIB=1024            # Write buffer size in KiB (0-65536)
CCBT_USE_MMAP=true                    # Use memory mapping (true/false)
CCBT_MMAP_CACHE_MB=128                # Memory-mapped cache size in MB (16-2048)
CCBT_MMAP_CACHE_CLEANUP_INTERVAL=30.0 # MMap cache cleanup interval (1.0-300.0)

# Hash verification
CCBT_HASH_WORKERS=4                   # Number of hash verification workers (1-32)
CCBT_HASH_CHUNK_SIZE=65536            # Chunk size for hash verification (1024-1048576)
CCBT_HASH_BATCH_SIZE=4                # Number of pieces to verify in parallel batches (1-64)
CCBT_HASH_QUEUE_SIZE=100              # Hash verification queue size (10-500)

# I/O threading
CCBT_DISK_WORKERS=2                   # Number of disk I/O workers (1-16)
CCBT_DISK_QUEUE_SIZE=200              # Disk I/O queue size (10-1000)
CCBT_CACHE_SIZE_MB=256                # Cache size in MB (16-4096)

# Advanced settings
CCBT_DIRECT_IO=false                  # Use direct I/O (true/false)
CCBT_SYNC_WRITES=false                # Synchronize writes (true/false)
CCBT_READ_AHEAD_KIB=64                # Read ahead size in KiB (0-1024)
CCBT_ENABLE_IO_URING=false            # Enable io_uring on Linux if available (true/false)
CCBT_DOWNLOAD_PATH=                   # Default download path

# Checkpoint settings
CCBT_CHECKPOINT_ENABLED=true          # Enable download checkpointing (true/false)
CCBT_CHECKPOINT_FORMAT=both           # Checkpoint file format (json/binary/both)
CCBT_CHECKPOINT_DIR=                  # Checkpoint directory (defaults to download_dir/.ccbt/checkpoints)
CCBT_CHECKPOINT_INTERVAL=30.0         # Checkpoint save interval in seconds (1.0-3600.0)
CCBT_CHECKPOINT_ON_PIECE=true         # Save checkpoint after each verified piece (true/false)
CCBT_AUTO_RESUME=true                 # Automatically resume from checkpoint on startup (true/false)
CCBT_CHECKPOINT_COMPRESSION=true      # Compress binary checkpoint files (true/false)
CCBT_AUTO_DELETE_CHECKPOINT_ON_COMPLETE=true # Auto-delete checkpoint when download completes (true/false)
CCBT_CHECKPOINT_RETENTION_DAYS=30     # Days to retain checkpoints before cleanup (1-365)

# Fast Resume settings
CCBT_FAST_RESUME_ENABLED=true         # Enable fast resume support (true/false)
CCBT_RESUME_SAVE_INTERVAL=30.0        # Interval to save resume data in seconds (1.0-3600.0)
CCBT_RESUME_VERIFY_ON_LOAD=true       # Verify resume data integrity on load (true/false)
CCBT_RESUME_VERIFY_PIECES=10          # Number of pieces to verify on resume (0-100, 0 = disable)
CCBT_RESUME_DATA_FORMAT_VERSION=1     # Resume data format version (1-100)

# BEP 47: File Attributes Configuration
CCBT_ATTRIBUTES_PRESERVE_ATTRIBUTES=true  # Preserve file attributes (executable, hidden, symlinks) (true/false)
CCBT_ATTRIBUTES_SKIP_PADDING_FILES=true  # Skip downloading padding files (BEP 47) (true/false)
CCBT_ATTRIBUTES_VERIFY_FILE_SHA1=false   # Verify file SHA-1 hashes when provided (BEP 47) (true/false)
CCBT_ATTRIBUTES_APPLY_SYMLINKS=true       # Create symlinks for files with attr='l' (true/false)
CCBT_ATTRIBUTES_APPLY_EXECUTABLE_BIT=true # Set executable bit for files with attr='x' (true/false)
CCBT_ATTRIBUTES_APPLY_HIDDEN_ATTR=true    # Apply hidden attribute for files with attr='h' (Windows) (true/false)

# XET Protocol Configuration
CCBT_XET_ENABLED=false                   # Enable Xet protocol for content-defined chunking and deduplication (true/false)
CCBT_XET_CHUNK_MIN_SIZE=8192            # Minimum Xet chunk size in bytes
CCBT_XET_CHUNK_MAX_SIZE=131072          # Maximum Xet chunk size in bytes
CCBT_XET_CHUNK_TARGET_SIZE=16384        # Target Xet chunk size in bytes
CCBT_XET_DEDUPLICATION_ENABLED=true     # Enable chunk-level deduplication (true/false)
CCBT_XET_CACHE_DB_PATH=                 # Path to Xet deduplication cache database
CCBT_XET_CHUNK_STORE_PATH=              # Path to Xet chunk storage directory
CCBT_XET_USE_P2P_CAS=true               # Use peer-to-peer Content Addressable Storage (DHT-based) (true/false)
CCBT_XET_COMPRESSION_ENABLED=false      # Enable LZ4 compression for stored chunks (true/false)

# =============================================================================
# STRATEGY CONFIGURATION
# =============================================================================

# Piece selection strategy: round_robin, rarest_first, sequential
CCBT_PIECE_SELECTION=rarest_first     # Piece selection strategy
CCBT_ENDGAME_DUPLICATES=2             # Endgame duplicate requests (1-10)
CCBT_ENDGAME_THRESHOLD=0.95           # Endgame mode threshold (0.1-1.0)
CCBT_STREAMING_MODE=false              # Enable streaming mode (true/false)

# Advanced strategy settings
CCBT_RAREST_FIRST_THRESHOLD=0.1       # Rarest first threshold (0.0-1.0)
CCBT_SEQUENTIAL_WINDOW=10             # Sequential window size (1-100)
CCBT_SEQUENTIAL_PRIORITY_FILES=       # File paths to prioritize in sequential mode (comma-separated, optional)
CCBT_SEQUENTIAL_FALLBACK_THRESHOLD=0.1 # Fallback to rarest-first if availability < threshold (0.0-1.0)
CCBT_PIPELINE_CAPACITY=4              # Request pipeline capacity (1-32)

# Piece priorities
CCBT_FIRST_PIECE_PRIORITY=true        # Prioritize first piece (true/false)
CCBT_LAST_PIECE_PRIORITY=false        # Prioritize last piece (true/false)

# =============================================================================
# DISCOVERY CONFIGURATION
# =============================================================================

# DHT settings
CCBT_ENABLE_DHT=true                  # Enable DHT (true/false)
CCBT_DHT_PORT=6882                    # DHT port (1024-65535)
# DHT bootstrap nodes (comma-separated)
CCBT_DHT_BOOTSTRAP_NODES=router.bittorrent.com:6881,dht.transmissionbt.com:6881,router.utorrent.com:6881,dht.libtorrent.org:25401,dht.aelitis.com:6881,router.silotis.us:6881,router.bitcomet.com:6881

# BEP 32: IPv6 Extension for DHT
CCBT_DHT_ENABLE_IPV6=true             # Enable IPv6 DHT support (BEP 32) (true/false)
CCBT_DHT_PREFER_IPV6=true             # Prefer IPv6 addresses over IPv4 when available (true/false)
# IPv6 DHT bootstrap nodes (comma-separated, format: [hostname:port or [IPv6]:port])
CCBT_DHT_IPV6_BOOTSTRAP_NODES=

# BEP 43: Read-only DHT Nodes
CCBT_DHT_READONLY_MODE=false          # Enable read-only DHT mode (BEP 43) (true/false)

# BEP 45: Multiple-Address Operation for DHT
CCBT_DHT_ENABLE_MULTIADDRESS=true     # Enable multi-address support (BEP 45) (true/false)
CCBT_DHT_MAX_ADDRESSES_PER_NODE=4     # Maximum addresses to track per node (BEP 45) (1-16)

# BEP 44: Storing Arbitrary Data in the DHT
CCBT_DHT_ENABLE_STORAGE=false         # Enable DHT storage (BEP 44) (true/false)
CCBT_DHT_STORAGE_TTL=3600             # Storage TTL in seconds (BEP 44) (60-86400)
CCBT_DHT_MAX_STORAGE_SIZE=1000        # Maximum storage value size in bytes (BEP 44) (100-10000)

# BEP 51: DHT Infohash Indexing
CCBT_DHT_ENABLE_INDEXING=true         # Enable infohash indexing (BEP 51) (true/false)
CCBT_DHT_INDEX_SAMPLES_PER_KEY=8     # Maximum samples per index key (BEP 51) (1-100)

# XET chunk discovery settings
CCBT_XET_CHUNK_QUERY_BATCH_SIZE=50   # Batch size for parallel chunk queries (1-200)
CCBT_XET_CHUNK_QUERY_MAX_CONCURRENT=50 # Maximum concurrent chunk queries (1-200)
CCBT_DISCOVERY_CACHE_TTL=60.0        # Discovery result cache TTL in seconds (1.0-3600.0)

# PEX settings
CCBT_ENABLE_PEX=true                  # Enable Peer Exchange (true/false)
CCBT_PEX_INTERVAL=30.0                # Peer Exchange announce interval in seconds (5.0-3600.0)

# Tracker settings
CCBT_ENABLE_HTTP_TRACKERS=true        # Enable HTTP trackers (true/false)
CCBT_ENABLE_UDP_TRACKERS=true         # Enable UDP trackers (true/false)
CCBT_TRACKER_ANNOUNCE_INTERVAL=1800.0 # Tracker announce interval in seconds (60.0-86400.0)
CCBT_TRACKER_SCRAPE_INTERVAL=3600.0   # Tracker scrape interval in seconds (60.0-86400.0)
CCBT_TRACKER_AUTO_SCRAPE=false        # Automatically scrape trackers when adding torrents (true/false)
# Default trackers for magnet links without tr= parameters (comma-separated)
CCBT_DEFAULT_TRACKERS=https://tracker.opentrackr.org:443/announce,https://tracker.torrent.eu.org:443/announce,https://tracker.openbittorrent.com:443/announce,http://tracker.opentrackr.org:1337/announce,http://tracker.openbittorrent.com:80/announce,udp://tracker.opentrackr.org:1337/announce,udp://tracker.openbittorrent.com:80/announce

# Private torrent settings (BEP 27)
CCBT_STRICT_PRIVATE_MODE=true         # Enforce strict BEP 27 rules for private torrents (true/false)

# IMPROVEMENT: Aggressive discovery for popular torrents
CCBT_AGGRESSIVE_DISCOVERY_POPULAR_THRESHOLD=20  # Minimum peer count to enable aggressive discovery mode (5-100)
CCBT_AGGRESSIVE_DISCOVERY_ACTIVE_THRESHOLD_KIB=1.0  # Minimum download rate (KB/s) to enable aggressive discovery mode (0.1-100.0)
CCBT_AGGRESSIVE_DISCOVERY_INTERVAL_POPULAR=10.0  # DHT query interval in seconds for popular torrents (20+ peers) (5.0-60.0)
CCBT_AGGRESSIVE_DISCOVERY_INTERVAL_ACTIVE=5.0  # DHT query interval in seconds for actively downloading torrents (>1KB/s) (2.0-30.0)
CCBT_AGGRESSIVE_DISCOVERY_MAX_PEERS_PER_QUERY=100  # Maximum peers to query per DHT query in aggressive mode (50-500)

# DHT query parameters (Kademlia algorithm)
CCBT_DHT_NORMAL_ALPHA=5                  # Number of parallel queries for normal DHT lookups (BEP 5 alpha parameter) (3-20)
CCBT_DHT_NORMAL_K=16                    # Bucket size for normal DHT lookups (BEP 5 k parameter) (8-64)
CCBT_DHT_NORMAL_MAX_DEPTH=12            # Maximum depth for normal DHT iterative lookups (3-30)
CCBT_DHT_AGGRESSIVE_ALPHA=8             # Number of parallel queries for aggressive DHT lookups (BEP 5 alpha parameter) (5-30)
CCBT_DHT_AGGRESSIVE_K=32                # Bucket size for aggressive DHT lookups (BEP 5 k parameter) (16-128)
CCBT_DHT_AGGRESSIVE_MAX_DEPTH=15        # Maximum depth for aggressive DHT iterative lookups (5-50)

# =============================================================================
# OBSERVABILITY CONFIGURATION
# =============================================================================

# Logging
CCBT_LOG_LEVEL=INFO                   # Log level (DEBUG/INFO/WARNING/ERROR/CRITICAL)
CCBT_LOG_FILE=                        # Log file path (empty = stdout)
CCBT_LOG_FORMAT=%(asctime)s - %(name)s - %(levelname)s - %(message)s # Log format string
CCBT_STRUCTURED_LOGGING=true          # Use structured logging (true/false)
CCBT_LOG_CORRELATION_ID=true          # Include correlation IDs (true/false)

# Metrics
CCBT_ENABLE_METRICS=true             # Enable metrics collection (true/false)
CCBT_METRICS_PORT=9090               # Metrics port (1024-65535)
CCBT_METRICS_INTERVAL=5.0            # Metrics collection interval in seconds (0.5-3600.0)

# Tracing
CCBT_ENABLE_PEER_TRACING=false       # Enable peer tracing (true/false)
CCBT_TRACE_FILE=                     # Path to write traces (empty = disabled)
CCBT_ALERTS_RULES_PATH=.ccbt/alerts.json # Path to alert rules JSON file

# Event bus configuration
CCBT_EVENT_BUS_MAX_QUEUE_SIZE=10000  # Maximum size of event queue (100-1000000)
CCBT_EVENT_BUS_BATCH_SIZE=50         # Maximum number of events to process per batch (1-1000)
CCBT_EVENT_BUS_BATCH_TIMEOUT=0.05    # Timeout in seconds to wait when collecting a batch (0.001-1.0)
CCBT_EVENT_BUS_EMIT_TIMEOUT=0.01     # Timeout in seconds when trying to emit to a full queue (0.001-1.0)
CCBT_EVENT_BUS_QUEUE_FULL_THRESHOLD=0.9  # Queue fullness threshold (0.0-1.0) for dropping low-priority events (0.1-1.0)
CCBT_EVENT_BUS_THROTTLE_DHT_NODE_FOUND=0.1  # Throttle interval for dht_node_found events in seconds (max 10/sec) (0.001-10.0)
CCBT_EVENT_BUS_THROTTLE_DHT_NODE_ADDED=0.1  # Throttle interval for dht_node_added events in seconds (max 10/sec) (0.001-10.0)
CCBT_EVENT_BUS_THROTTLE_MONITORING_HEARTBEAT=1.0  # Throttle interval for monitoring_heartbeat events in seconds (max 1/sec) (0.1-60.0)
CCBT_EVENT_BUS_THROTTLE_GLOBAL_METRICS_UPDATE=0.5  # Throttle interval for global_metrics_update events in seconds (max 2/sec) (0.1-10.0)

# =============================================================================
# LIMITS CONFIGURATION
# =============================================================================

# Global rate limits (KiB/s, 0 = unlimited)
CCBT_LIMITS_GLOBAL_DOWN_KIB=0        # Global download limit (0+)
CCBT_LIMITS_GLOBAL_UP_KIB=0          # Global upload limit (0+)

# Per-torrent rate limits (KiB/s, 0 = unlimited)
CCBT_LIMITS_PER_TORRENT_DOWN_KIB=0   # Per-torrent download limit (0+)
CCBT_LIMITS_PER_TORRENT_UP_KIB=0     # Per-torrent upload limit (0+)

# Per-peer rate limits (KiB/s, 0 = unlimited)
CCBT_LIMITS_PER_PEER_UP_KIB=0        # Per-peer upload limit (0+)

# Scheduler settings
CCBT_SCHEDULER_SLICE_MS=100          # Scheduler time slice in ms (1-1000)

# =============================================================================
# SECURITY CONFIGURATION
# =============================================================================

CCBT_ENABLE_ENCRYPTION=false          # Enable protocol encryption (true/false)
CCBT_ENCRYPTION_MODE=preferred         # Encryption mode: disabled/preferred/required
CCBT_ENCRYPTION_DH_KEY_SIZE=768        # DH key size in bits: 768 or 1024
CCBT_ENCRYPTION_PREFER_RC4=true       # Prefer RC4 cipher for compatibility (true/false)
CCBT_ENCRYPTION_ALLOWED_CIPHERS=rc4,aes # Allowed ciphers (comma-separated: rc4,aes,chacha20)
CCBT_ENCRYPTION_ALLOW_PLAIN_FALLBACK=true # Allow fallback to plain connection (true/false)
CCBT_VALIDATE_PEERS=true               # Validate peers before exchanging data (true/false)
CCBT_RATE_LIMIT_ENABLED=true           # Enable security rate limiter (true/false)
CCBT_MAX_CONNECTIONS_PER_PEER=1        # Maximum parallel connections per peer (1-8)

# IP Filter settings
CCBT_ENABLE_IP_FILTER=false               # Enable IP filtering (true/false)
CCBT_FILTER_MODE=block                    # Filter mode: block or allow
CCBT_FILTER_FILES=                        # Comma-separated filter file paths
CCBT_FILTER_URLS=                         # Comma-separated filter list URLs
CCBT_FILTER_UPDATE_INTERVAL=86400.0      # Update interval in seconds (3600.0-604800.0)
CCBT_FILTER_CACHE_DIR=~/.ccbt/filters    # Filter cache directory
CCBT_FILTER_LOG_BLOCKED=true             # Log blocked connections (true/false)

# Blacklist settings
CCBT_BLACKLIST_ENABLE_PERSISTENCE=true    # Persist blacklist to disk (true/false)
CCBT_BLACKLIST_FILE=~/.ccbt/security/blacklist.json  # Path to blacklist file
CCBT_BLACKLIST_AUTO_UPDATE_ENABLED=false  # Enable automatic blacklist updates from external sources (true/false)
CCBT_BLACKLIST_AUTO_UPDATE_INTERVAL=3600.0  # Auto-update interval in seconds (5m-24h)
CCBT_BLACKLIST_AUTO_UPDATE_SOURCES=       # URLs for automatic blacklist updates (comma-separated)
CCBT_BLACKLIST_DEFAULT_EXPIRATION_HOURS=  # Default expiration time for auto-blacklisted IPs in hours (empty = permanent)

# Local metric-based blacklist source
CCBT_BLACKLIST_LOCAL_SOURCE_ENABLED=true  # Enable local metric-based blacklisting (true/false)
CCBT_BLACKLIST_LOCAL_SOURCE_EVALUATION_INTERVAL=300.0  # Evaluation interval in seconds (1m-1h)
CCBT_BLACKLIST_LOCAL_SOURCE_METRIC_WINDOW=3600.0  # Metric aggregation window in seconds (5m-24h)
CCBT_BLACKLIST_LOCAL_SOURCE_EXPIRATION_HOURS=24.0  # Expiration time for auto-blacklisted IPs (hours, empty = permanent)
CCBT_BLACKLIST_LOCAL_SOURCE_MIN_OBSERVATIONS=3  # Minimum observations before blacklisting

# =============================================================================
# SSL/TLS CONFIGURATION
# =============================================================================

# SSL/TLS settings
CCBT_ENABLE_SSL_TRACKERS=true              # Enable SSL for tracker connections (true/false)
CCBT_ENABLE_SSL_PEERS=false                # Enable SSL for peer connections (true/false)
CCBT_SSL_VERIFY_CERTIFICATES=true          # Verify SSL certificates (true/false)
CCBT_SSL_CA_CERTIFICATES=                  # Path to CA certificates file or directory
CCBT_SSL_CLIENT_CERTIFICATE=               # Path to client certificate file (PEM format)
CCBT_SSL_CLIENT_KEY=                       # Path to client private key file (PEM format)
CCBT_SSL_PROTOCOL_VERSION=TLSv1.2          # TLS protocol version (TLSv1.2, TLSv1.3, PROTOCOL_TLS)
CCBT_SSL_ALLOW_INSECURE_PEERS=true         # Allow insecure peers for opportunistic encryption (true/false)

# =============================================================================
# PROXY CONFIGURATION
# =============================================================================

CCBT_PROXY_ENABLE_PROXY=false          # Enable proxy support (true/false)
CCBT_PROXY_TYPE=http                   # Proxy type: http/socks4/socks5
CCBT_PROXY_HOST=                        # Proxy server hostname or IP
CCBT_PROXY_PORT=                        # Proxy server port (1-65535)
CCBT_PROXY_USERNAME=                    # Proxy username for authentication
CCBT_PROXY_PASSWORD=                    # Proxy password (encrypted in storage)
CCBT_PROXY_FOR_TRACKERS=true            # Use proxy for tracker requests (true/false)
CCBT_PROXY_FOR_PEERS=false              # Use proxy for peer connections (true/false)
CCBT_PROXY_FOR_WEBSEEDS=true            # Use proxy for WebSeed requests (true/false)
CCBT_PROXY_BYPASS_LIST=                 # Comma-separated list of hosts/IPs to bypass proxy

# =============================================================================
# MACHINE LEARNING CONFIGURATION
# =============================================================================

CCBT_ML_PEER_SELECTION_ENABLED=false # Enable ML-based peer selection (true/false)
CCBT_ML_PIECE_PREDICTION_ENABLED=false # Enable ML piece prediction (true/false)

# =============================================================================
# NAT CONFIGURATION
# =============================================================================

CCBT_NAT_ENABLE_NAT_PMP=true             # Enable NAT-PMP protocol (true/false)
CCBT_NAT_ENABLE_UPNP=true                # Enable UPnP IGD protocol (true/false)
CCBT_NAT_DISCOVERY_INTERVAL=300.0        # NAT device discovery interval in seconds (0.0-3600.0)
CCBT_NAT_PORT_MAPPING_LEASE_TIME=3600    # Port mapping lease time in seconds (60-86400)
CCBT_NAT_AUTO_MAP_PORTS=true             # Automatically map ports on startup (true/false)
CCBT_NAT_MAP_TCP_PORT=true               # Map TCP listen port (true/false)
CCBT_NAT_MAP_UDP_PORT=true               # Map UDP listen port (true/false)
CCBT_NAT_MAP_DHT_PORT=true               # Map DHT UDP port (true/false)
CCBT_NAT_MAP_XET_PORT=true               # Map XET protocol UDP port (true/false)
CCBT_NAT_MAP_XET_MULTICAST_PORT=false    # Map XET multicast UDP port (usually not needed for multicast) (true/false)

# =============================================================================
# UI/INTERNATIONALIZATION CONFIGURATION
# =============================================================================

CCBT_LOCALE=en                    # Language/locale code (e.g., 'en', 'es', 'fr', 'hi', 'ur', 'fa', 'ja', 'ko', 'zh', 'th', 'sw', 'ha', 'yo', 'eu', 'arc')
CCBT_UI_LOCALE=                   # UI-specific locale override (takes precedence over CCBT_LOCALE if set)

# Locale precedence order (highest to lowest):
# 1. CCBT_UI_LOCALE environment variable
# 2. CCBT_LOCALE environment variable
# 3. LANG environment variable
# 4. Config file [ui] section (ccbt.toml)
# 5. System locale
# 6. Default locale ('en')

# Available locales: en, es, fr, hi, ur, fa, arc, ja, ko, zh, th, sw, ha, yo, eu
# If an invalid locale is specified, the system will fall back to 'en'

# =============================================================================
# CLI-SPECIFIC OVERRIDES
# =============================================================================
# These can be used to override any configuration value via environment variables
# Format: CCBT_<SECTION>_<OPTION>=<value>
# Example: CCBT_NETWORK_LISTEN_PORT=8080

# =============================================================================
# DEVELOPMENT AND DEBUGGING
# =============================================================================

# Debug mode
CCBT_DEBUG=false                      # Enable debug mode (true/false)
CCBT_VERBOSE=false                    # Enable verbose output (true/false)

# Performance profiling
CCBT_ENABLE_PROFILING=false           # Enable performance profiling (true/false)
CCBT_PROFILE_OUTPUT=                  # Profile output file path

# Testing
CCBT_TEST_MODE=false                  # Enable test mode (true/false)
CCBT_MOCK_NETWORK=false              # Use mock network for testing (true/false)

# =============================================================================
# NOTES
# =============================================================================
# 1. All boolean values can be set as: true/false, 1/0, yes/no, on/off
# 2. Numeric values must be within the specified ranges
# 3. Enum values must match exactly (case-sensitive)
# 4. Empty values will use defaults
# 5. Environment variables take precedence over config file values
# 6. CLI arguments take precedence over environment variables
# 7. Use quotes for values containing spaces or special characters

CCBT_ENABLE_PROFILING=false           # Enable performance profiling (true/false)
CCBT_PROFILE_OUTPUT=                  # Profile output file path

# Testing
CCBT_TEST_MODE=false                  # Enable test mode (true/false)
CCBT_MOCK_NETWORK=false              # Use mock network for testing (true/false)

# =============================================================================
# NOTES
# =============================================================================
# 1. All boolean values can be set as: true/false, 1/0, yes/no, on/off
# 2. Numeric values must be within the specified ranges
# 3. Enum values must match exactly (case-sensitive)
# 4. Empty values will use defaults
# 5. Environment variables take precedence over config file values
# 6. CLI arguments take precedence over environment variables
# 7. Use quotes for values containing spaces or special characters
